import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import api from './api/apiService'
import store from './store'
import Notification from './components/Notification.vue'

// 配置axios
axios.defaults.baseURL = 'http://localhost:5001'
axios.defaults.headers.post['Content-Type'] = 'application/json'

// 创建Vue应用实例
const app = createApp(App)

// 注册Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 使用插件
app.use(ElementPlus)
app.use(router)

// 挂载全局属性
app.config.globalProperties.$axios = axios
app.config.globalProperties.$api = api
app.config.globalProperties.$store = store

// 注册全局组件
app.component('Notification', Notification)

// 挂载应用
app.mount('#app')